<?php

namespace App\Containers\AppSection\Project\UI\API\Transformers;

use App\Containers\AppSection\Project\Models\Government;
use App\Containers\AppSection\Type\UI\API\Transformers\TypeTransformer;
use App\Ship\Parents\Transformers\Transformer;
use League\Fractal\Resource\Item;

class GovernmentTransformer extends Transformer
{
    protected array $defaultIncludes = [
        'type'
    ];

    public function transform(Government $t): array
    {
        return [
            'object' => $t->getResourceKey(),
            'include' => $this->getAvailableIncludes(),
            'id' => $t->getHashedKey(),
            'type_key' => $t->type_key,
            'participants' => $t->participants,
            'body_name' => $t->body_name,
            'participants_name' => $t->participants_name,
            'persons_information' => $t->persons_information,
        ];
    }

    public function includeType(Government $t): Item
    {
        return $this->item($t->type, new TypeTransformer);
    }
}
